package com.newcapec.news.servlet;

import com.newcapec.news.dao.NewsDao;
import com.newcapec.news.dao.impl.NewsDaoImpl;
import com.newcapec.news.entity.Channel;
import com.newcapec.news.entity.News;
import com.newcapec.news.service.ChannelService;
import com.newcapec.news.service.impl.ChannelServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description: 登录页面的展示
 * @Author: fujun
 * @Date : 2022/3/16 16:08
 * @Version : 1.0
 * @company 新开普电子股份有限公司
 */
@WebServlet("/page/NewsManagement.html")
public class ShowNewsHtmlServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//            req.setCharacterEncoding("utf-8");
//            resp.setCharacterEncoding("utf-8");
        //跳转新闻列表的jsp页面    我们给jsp页面传递一些数据


        NewsDao newsDao=new NewsDaoImpl();

        List<News> news = newsDao.queryNews();

        req.setAttribute("news",news);

        req.getRequestDispatcher("../WEB-INF/page/NewsManagement.jsp").forward(req,resp);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
